package com.zy.bootdemo.service.impl;

import com.zy.bootdemo.entity.TypeEntity;
import com.zy.bootdemo.mapper.TypeMapper;
import com.zy.bootdemo.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImpl implements TypeService{
    @Autowired(required = false)
    private TypeMapper typeMapper;
    @Override
    public List<TypeEntity> selectAll(String condition){
        return typeMapper.selectAll(condition);
    }
    @Override
    public boolean insertOne(TypeEntity typeEntity){
        if (typeEntity.getTName() == null || typeEntity.getTName() == "")return false;
        int row = typeMapper.insertOne(typeEntity);
        if (row !=0){
            return true;
        }
        return false;
    }

    @Override
    public boolean delOne(Integer id) {
        if (id == null || id == 0)return false;
        int row = typeMapper.delOne(id);
        return row != 0;
    }

    @Override
    public TypeEntity selectOne(Integer id) {
        return typeMapper.selectOne(id);
    }

    @Override
    public boolean update(TypeEntity type) {
        if (type == null || type.getTName() == null || type.getTName().equals(""))return false;
        int row = typeMapper.update(type);
        return row != 0;
    }


}
